package com.paging.controller;

import com.paging.pojo.Book;
import com.paging.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 位置：SSM/com.paging.controller
 * 时间：2023-04-24-18:19
 * 作者：Administrator
 **/


@Controller
public class BookController {

    @RequestMapping("/paging")
    public String paging() {
        return "paging";
    }


    @Autowired
    BookService bookService;


    @PostMapping("/queryBookList")
    @ResponseBody
    public List<Book> queryBookList() {
        return bookService.queryBookList();
    }

    @PostMapping("/getRowCount")
    @ResponseBody
    public int count(String bookName, String bookType) {
        return bookService.count(bookName,bookType);
    }

    @PostMapping("/addBook")
    @ResponseBody
    public void addBook(Book book) {
        bookService.addBook(book);
    }

    @PostMapping("/deleteBookByNumber")
    @ResponseBody
    public void deleteBookByNumber(String bookNumber) {
        bookService.deleteBook(bookNumber);
    }

    @PostMapping("/updateBook")
    @ResponseBody
    public void updateBook(Book book) {
        bookService.updateBook(book);
    }

    @PostMapping("/deleteBookByIds")
    @ResponseBody
    public void deleteBookByIds(String idList) {
        bookService.deleteBookByIds(idList);
    }

    @PostMapping("/queryBookListByPage")
    @ResponseBody
    public List<Book> queryBookListByPage(@RequestParam("page") Integer start, Integer pageSize, String bookName, String bookType) {
        System.out.println("start:"+start);
        System.out.println("pageSize:"+pageSize);
        return bookService.queryBookListByPage(start, pageSize, bookName, bookType);
    }

}
